package com.shop.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shop.domain.Classify;
import com.shop.goods.mapper.ClassifyMapper;
import com.shop.goods.service.ClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 靳润波
* @description 针对表【goods_classify】的数据库操作Service实现
* @createDate 2024-07-30 11:18:58
*/
@Service
public class ClassifyServiceImpl extends ServiceImpl<ClassifyMapper, Classify>
    implements ClassifyService{
    @Autowired
    private ClassifyMapper classifyMapper;
    @Override
    public List<Classify> selectAll() {
        LambdaQueryWrapper<Classify> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Classify::getIsDelete,0);
        return classifyMapper.selectList(wrapper);
    }

    @Override
    public Integer insert(Classify iClassify) {
        return classifyMapper.insert(iClassify);
    }

    @Override
    public Integer update(Classify classify) {
        return classifyMapper.updateById(classify);
    }

    @Override
    public Integer delete(Integer id) {
        Classify c = classifyMapper.selectById(id);
        if(c.getIsDelete()==1){
            return -1;
        }
        Classify classify = new Classify();
        classify.setId(Long.valueOf(id));
        classify.setIsDelete(1);
        return classifyMapper.updateById(classify);
    }
}




